package com.njsoft.bodyawakening.view;

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;


import com.njsoft.bodyawakening.R;
import com.njsoft.bodyawakening.photo.PhotoUtils;
import com.njsoft.bodyawakening.utils.AnimationUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * 日期选择
 *
 * @author 某人
 */
public class PhotoDialog extends DialogFragment {


    Unbinder unbinder;
    @BindView(R.id.mCamera)
    TextView mCamera;
    @BindView(R.id.mPhoto)
    TextView mPhoto;
    @BindView(R.id.mCancel)
    TextView mCancel;

    public static PhotoDialog newIntance() {
        return new PhotoDialog();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_photo, container, false);
        AnimationUtils.slideToUp(view);
        unbinder = ButterKnife.bind(this, view);

        return view;
    }

    @Override
    public void onStart() {
        super.onStart();
        Window window = getDialog().getWindow();
        WindowManager.LayoutParams params = window.getAttributes();
        params.gravity = Gravity.BOTTOM;
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        window.setAttributes(params);
        window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.mCamera, R.id.mPhoto, R.id.mCancel})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.mCamera:
                //相机
                PhotoUtils.setCAMERAPermission(getActivity(), "paizhao");

                break;
            case R.id.mPhoto:
                PhotoUtils.setCAMERAPermission(getActivity(), "Photos");
                //拍照
                break;
            case R.id.mCancel:
                break;
        }
        dismiss();
    }

}
